home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Apple II Magazines (PO)
/
Nibble Volume 12, No. 10 (1991-10)(MindCraft Publishing)(Side A)[a].zip
/
Nibble Volume 12, No. 10 (1991-10)(MindCraft Publishing)(Side A)[a].po
/
SETPBUF.ASM.txt
< prev
next >
Wrap
Text File
|
1996-12-24
|
12KB
|
368 lines
**************************************************
* *
* SETPBUF.ASM Source Listing *
* by Sandy Mossberg *
* *
* APW Assembler *
* *
* Application sets size of printer buffer used *
* by serial port firmware. Set your values for *
* MyPrtPort and MyBufSize. *
* *
* Copyright (C) 1991 *
* by MindCraft Publ. Corp. *
* Lincoln, MA 01773 *
* *
**************************************************
mcopy setpbuf.mac
keep setpbuf
BZHndl gequ $00 ;bank 0 handle
BZPtr gequ $04 ;bank 0 ptr
BufHndl gequ $08 ;buffer handle
Emulstack gequ $010100 ;emulation stack ptr
MyPrtPort gequ 1 ;printer slot=1
MyBufSize gequ $FFFF ;buffer size=64K
*********************************************
*
MainLoop start
*
* Main program loop:
*
*********************************************
using Globals
phk
plb
jsr StartTools ;startup tools
jsr SetBufData ;set print buffer
jsr ShutTools ;shutdown tools
_QuitGS QuitParm
end
*********************************************
*
StartTools start
*
* Startup tools:
*
*********************************************
using Globals
_TLStartUp
pha result space
_MMStartUp
PullWord MasterID save master ID
_MTStartUp
rts
end
*********************************************
*
ShutTools start
*
* Shutdown tools:
*
*********************************************
using Globals
_MTShutDown
PushWord MasterID ;master ID
_MMShutDown
_TLShutDown
rts
end
*********************************************
*
SetBufData start
*
* Set size of serial port printer buffer:
*
*********************************************
using Globals
; Reserve bank 0 space for serial port calls:
PushLong #0 ;result space
PushLong #BZEnd-BZStart ;size
PushWord MasterID ;master ID
PushWord #$C005 ;attributes
PushLong #0 ;use bank 0
_NewHandle
PullLong BZHndl ;save handle
bcc GetBZPtr ;no error
brl GoErrExit ;error
; Modify call addresses to bank 0 code:
GetBZPtr lda [BZHndl] ;dereference handle
sta BZPtr
sta GoBZ1+1 ;MODIFY address
sta GoBZ2+1 ;MODIFY address
ldy #2
lda [BZHndl],y
sta BZPtr+2
; Modify code to reflect printer's slot ROM:
shortm ;8-bit A/memory
lda #MyPrtPort ;slot number
asl a ;move slot to hi nibble
asl a
asl a
asl a
sta InitY+1 ;MODIFY address
lda #$C0
ora #MyPrtPort ;slot ROM address
sta InitX+1 ;MODIFY address
sta GetInit+2 ;MODIFY address
sta GetExtend+2 ;MODIFY address
sta DoInit+2 ;MODIFY address
sta DoGIB+2 ;MODIFY address
sta DoGOB+2 ;MODIFY address
sta DoSIB+2 ;MODIFY address
sta DoSOB+2 ;MODIFY address
; Modify dispatch addresses (init=Cn0D, extended = Cn12):
GetInit lda >$C00D ;MODIFIED
sta DoInit+1 ;MODIFY address
GetExtend lda >$C012 ;MODIFIED
sta DoGIB+1 ;MODIFY address
sta DoGOB+1 ;MODIFY address
sta DoSIB+1 ;MODIFY address
sta DoSOB+1 ;MODIFY address
; Copy image of bank 0 code to bank 0:
ldy #BZEnd-BZStart-1
CopyLoop lda BZStart,y
sta [BZPtr],y
dey
bpl CopyLoop
; Invoke serial port calls in bank 0 to get
; addresses of I/O buffers (pass 1):
long ;16-bit regs
GoBZ1 jsl $001000 ;MODIFIED
; Get attributes and ID of input buffer:
PushLong #0 ;result space
PushLong GIBBufAdr ;ptr to memory
_FindHandle
PullLong BufHndl ;inbuf handle
ldy #4
lda [BufHndl],y
sta FirmAttrib ;inbuf attributes
ldy #6
lda [BufHndl],y
sta FirmID ;inbuf ID
ldy #6
; Dispose of handle(s) to I/O buffer memory:
PushLong BufHndl ;kill handle to inbuf
_DisposeHandle
PushLong #0 ;result space
PushLong GOBBufAdr ;ptr to memory
_FindHandle ;outbuf handle
_DisposeHandle ;kill handle
; Allocate space for new I/O buffers:
PushLong #0 ;result space
PushLong #MyBufSize ;size
PushWord FirmID ;firmware ID
PushWord FirmAttrib ; and attributes
PushLong #0 ;not used
_NewHandle
PullLong BufHndl ;save handle
bcs GoErrExit ;error
; Set addresses in serial port command lists:
lda [BufHndl] ;dereference handle
sta SIBBufAdr ;inbuf lo
clc ;offset to outbuf
adc #$800
sta SOBBufAdr ;outbuf lo
ldy #2
lda [BufHndl],y
sta SIBBufAdr+2 ;inbuf hi
sta SOBBufAdr+2 ;outbuf hi
bcc SetBufLen
inc SOBBufAdr+2 ;bump hi word
; Set sizes in serial port command lists:
SetBufLen lda #800 ;2048 bytes
sta SIBBufLen ;inbuf size
lda #MyBufSize-$800
sta SOBBufLen ;outbuf size
; Invoke serial port calls in bank 0 to set
; addresses of I/O buffers (pass 2):
GoBZ2 jsl $001000 ;MODIFIED
bra Exit
; Set error flag and exit:
GoErrExit lda #-1
sta ErrFlag
Exit PushLong BZHndl ;kill handle to bank 0
_DisposeHandle
lda ErrFlag
beq Endit ;no error
_SysBeep ;error beep
Endit rts
;............................................
;
; IMAGE OF BANK ZERO CODE:
;
; Save entry environment:
BZStart long ;16-bit regs
phd ;save entry direct page
phb ;save entry data bank
tsc ;get stack ptr into
tax ; A,X-regs
shortm ;8-bit A/memory
xba
dec a
beq SaveSP ;stack ptr in page 1
lda #1 ;set stack ptr to pg 1
xba
lda Emulstack ;set emulation mode
tcs ; stack ptr
SaveSP phx ;save entry stack ptr
; Set emulation mode and new environment:
emulation ;emulation mode
pea 0
pld ;direct page=page 0
lda #0
pha
plb ;data bank=bank 0
; Check whether to set buffer info:
lda >BZFlag
beq SetSIBAdr ;it's pass 2
; Initialize serial port firmware on pass 1 (X=Cn, Y=n0):
InitX ldx #$C0 ;MODIFIED
InitY ldy #$00 ;MODIFIED
DoInit jsr $C000 ;MODIFIED
txa ;test X-reg
beq GetGIBAdr ;no error
dc h'00' ;crash
; Get buffer info on pass 1:
GetGIBAdr lda #GIBCmdList ;point to command list
ldx #>GIBCmdList
ldy #^GIBCmdList
DoGIB jsr $C000 ;MODIFIED
bcc GetGOBAdr ;no error
dc h'00' ;bomb
GetGOBAdr lda #GOBCmdList ;point to command list
ldx #>GOBCmdList
ldy #^GOBCmdList
DoGOB jsr $C000 ;MODIFIED
lda >BZFlag ;flag pass 2
dec a
sta >BZFlag
bcc BZRestore ;no error
dc h'00' ;to monitor
; Set buffer info on pass 2:
SetSIBAdr lda #SOBCmdList ;point to command list
ldx #>SOBCmdList
ldy #^SOBCmdList
DoSIB jsr $C000 ;MODIFIED
bcc SetSOBAdr ;no error
dc h'00' ;die hard
SetSOBAdr lda #SOBCmdList ;point to command list
ldx #>SOBCmdList
ldy #^SOBCmdList
DoSOB jsr $C000 ;MODIFIED
bcc BZRestore ;no error
dc h'00' ;arrrggh!
; Restore entry environment:
BZRestore native long ;full native mode
plx ;restore entry stack ptr
txs
plb ;restore entry data bank
pld ;restore entry direct page
rtl
BZEnd anop
end
*********************************************
*
Globals data
*
* Global data:
*
*********************************************
QuitParm dc i2'0' ;pCount = 0
MasterID ds 2 ;application ID
FirmAttrib ds 2 ;firmware attributes
FirmID ds 2 ;firmware ID
ErrFlag dc i2'0' ;0=no error, -1=error
BZFlag dc i1'1' ;1=pass 1=init/get info
; ;0=pass 2=set info
GIBCmdList anop ;GetInBuffer command list
dc h'04' ;pCount = 4
dc h'10' ;command code
ds 2 ;return code
GIBBufAdr ds 4 ;buffer address
GIBBufLen ds 2 ;buffer length
GOBCmdList anop ;GetOutBuffer command list
dc h'04' ;pCount = 4
dc h'11' ;command code
ds 2 ;return code
GOBBufAdr ds 4 ;buffer address
GOBBufLen ds 2 ;buffer length
SIBCmdList anop ;SetInBuffer command list
dc h'04' ;pCount = 4
dc h'12' ;command code
ds 2 ;return code
SIBBufAdr ds 4 ;buffer address
SIBBufLen ds 4 ;buffer length
SOBCmdList anop ;SetOutBuffer command list
dc h'04' ;pCount = 4
dc h'13' ;command code
ds 2 ;return code
SOBBufAdr ds 4 ;buffer address
SOBBufLen ds 4 ;buffer length
end